<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>事件修饰符</title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="root">
			<h2>欢迎来到{{name}}</h2>
			<!-- 阻止默认事件 -->
			<a href="http://www.baidu.com" @click.prevent="showInfo">点我提示信息</a>
			<!-- 阻止事件冒泡 -->
			<div id="test" @click="showInfo">
				<button type="button" @click.stop="showInfo">点击我提示</button>
			</div>
			<!-- 事件只触发一次 -->
			<button type="button" @click.once="showInfo">点击我提示</button>
			<!-- 使用事件的捕获模式 -->
			<div id="box1"  @click.capture="showMse(1)">
				box1
				<div id="box2"  @click="showMse(2)">
					div2
				</div>
			</div>
			<!--  -->
			<div id="test2" @click.self="showInfo">
				<button type="button" @click="showInfo">点击我提示</button>
			</div>
		</div>
		<script type="text/javascript">
			Vue.config.productionTip = false
			new Vue({
				el:"#root",
				data:{
					name:"尚硅谷"
				},
				methods:{
					showInfo(e){
						//e.preventDefault(); // 阻止a标签的默认行为
						//e.stopPropagation(); // 阻止事件的冒泡
						alert("你好同学");
					},
					showMse(mse){
						console.log(mse);
					}
				}
			})
		</script>
	</body>
</html>
